Skip to content

Conversation

@deruyter92
Copy link
Collaborator

@deruyter92 deruyter92 commented Jan 6, 2026

Problem description:
When loading an image folder, previous implementation only looked at the first file to create a glob pattern for loading all images in the folder. This has the disadvantage that files with different extensions cannot be loaded. See issue #3160 on the DeepLabCut repository.

Changes:
This commit changes image reading to be more flexible: input can be a single path, a glob pattern or a list of image paths. Images of different sizes are stacked using dask delayed arrays. (Mostly inspired by napari's own default implementation.)
When loading an image folder, all files with valid image extensions are selected inside that folder.

This commit changes image reading to be more flexible: input can be a single path, a glob pattern or a list of image paths. Images of different sizes are stacked using dask delayed arrays. (Mostly inspired by napari's own default implementation.)

Previous implementation only allowed for a glob pattern when loading multiple images. This has the disadvantage that files with different extensions cannot be loaded.

Fixes issue #3160 with multiple images that have different extensions.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances image loading flexibility by introducing a new lazy_imread function that accepts various input formats (single path, glob pattern, or list of image paths) and supports both dask and numpy arrays. The change addresses the limitation where only the first file's extension was used to create a glob pattern, preventing loading of image folders with mixed file extensions.

Changes:

  • Added _filter_extensions helper function to validate image paths by their extensions
  • Replaced folder parsing logic to collect all valid image files instead of creating a glob pattern from the first file
  • Introduced lazy_imread function with support for dask delayed arrays and flexible input formats

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@C-Achard
Copy link
Collaborator

@deruyter92 Sorry just asked Copilot out of curiosity, will work on this tomorrow!

@C-Achard
Copy link
Collaborator

@deruyter92 Due to some permissions issues across forks I had to reopen elsewhere after rebasing on #153; the updated+rebased version can be found here.
I suggest we merge #153 first and then I'll take care of this, then the tracking feature PR

@C-Achard
Copy link
Collaborator

C-Achard commented Jan 16, 2026

Update : opened #154 as replacement PR, sorry @deruyter92 everything I tried to push on your fork directly after rebasing failed so far; hopefully we can help avoid this in the future by not using forks, since we now have write access.

There's probably a way to do it but to save time I'll use the new PR.

@C-Achard C-Achard closed this Jan 16, 2026
@deruyter92
Copy link
Collaborator Author

Perfect! No problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants